//
//  BiliGroup.swift
//  Landmarks
//
//  Created by 温哲 on 2021/2/10.
//

import SwiftUI

struct BiliGroup: View {
    var models: [CommonModel]

    var body: some View {
        HStack(alignment: .center) {
            ForEach(models) { model in
                HStack {
                    Spacer()
                    ZStack {
                        VStack {
                            Image(model.image)
                            Text(model.name).font(Font.custom("PingFangSC-Regular", fixedSize: 12))
                        }
                        Text(model.tipsNum > 0 ? model.tipsNum.description : "").foregroundColor(.white)
                            .frame(width: 16.0, height: 16.0).font(Font.custom("PingFangSC-Regular", fixedSize: 10))
                            .background(model.tipsNum > 0 ? Color.red : Color.clear).cornerRadius(30.0).shadow(radius: 10).offset(x: 20.0, y: -30.0)
                    }
                    Spacer()
                }
            }
        }
    }
}

struct BiliGroup_Previews: PreviewProvider {
    static var previews: some View {
        BiliGroup(models:
            [CommonModel(id: 0, name: "我的课程", image: "msg_1", tipsNum: 0),
             CommonModel(id: 1, name: "看视频免流量", image: "msg_2", tipsNum: 10),
             CommonModel(id: 2, name: "个性装扮", image: "msg_3", tipsNum: 3),
             CommonModel(id: 3, name: "邀好友赚红包", image: "msg_4", tipsNum: 0)])
    }
}
